 <?
 
$cache_path = "data/" . $group_name . ".DAT";
if (! file_exists ($cache_path))			
{
   $msg = "<div id='dupdate'>Please wait while the newsgroup updates...</div>";
}
elseif ($action=="update")
{
    unlink ($cache_path);
	$qu = preg_replace("/[&?]*a=(\w+)/", "", $qs);  
	print "<script language='javascript'>location.href='newsgroups.php?" . $qu . "'</script>";
	exit;
}
{ 
    
	$content = implode ('', file ($cache_path));
	parse_str ($content);
	$msg = "<div id='dupdate'><a href=\"javascript:fb_edit('a','update')\" style=color:slateblue>Last updated " . date ("m/d/Y H:i:s", $timestamp) . "</a></div> ";
}
 
 ?>
 
 <table>
   <tr>
	  <td>
		  <img src="images/logo.gif">
	  </td>
	  <td nowrap>
		  <table>
			<tr>
			   <td nowrap id="td_search_options">
			 
			 <a class='normal'
			   href="newsgroups.php?sub=" 
			 >All Groups</a>&nbsp;&nbsp;&nbsp;
			 <a class='normal'
			   href="newsgroups.php?sub=on" 
			 >Subscribed Groups</a>&nbsp;&nbsp;&nbsp;
			  Messages&nbsp;&nbsp;&nbsp;
			 <a class='normal' href='javascript:show_detail()'
			 >Message</a>
			 
			   </td>
			</tr>
			<tr>
			<form action="newsgroups.php" method="get">
			   <td nowrap id="td_search_panel"> 
					<input type="text" name="fi" value='<?= $search_param ?>' >
					
										<?
						if (array_search($group_name,$sg_c)===false)
						{
						   print "&nbsp;<a href=\"javascript:fb_edit ('a', 'subscribe')\">Subscribe</a>";
						}
						else
						{
						   print "&nbsp;<a href=\"javascript:fb_edit ('a', 'unsubscribe')\">Unsubscribe</a>";
						}
										?>
					
					<input type="hidden" name="g"  value='<?= $group_name ?>' >
					<input type="submit" value="Search">
					<input type="button" value="Reset" onclick="fb_edit('fi', '', 's', '', 'k', '')">
					
					&nbsp;&nbsp;&nbsp;
					Results per page:
					<span id="spgsize"><input type="text" disabled id="pgsize" value="<?= RESULT_PAGE_SIZE ?>" size="2"></span>	   
		  <br>
		  <?= $msg ?>
				</td>
			</form>
			</tr>
		  </table> 
	  </td>
	  <td nowrap>
		  <? 
		  print "<a href=\"javascript:fb_edit('pp_v',";
		  if ($pp_v=="")
		  {
		     print "'thumb')\">Switch to Preview mode</a>";
		  }
		  else
		  {
		     print "'')\">Switch to List mode</a>";
		  } ?>
	  </td>
   </tr>
</table>

<div style="width:100%;border-top:solid 1px #339999;background-color:#CCFFCC;padding:3px">

<table width="100%" cellpadding="1" cellspacing="1">
	<tr>
		<td>
			<div id="dpages">
	 

<?
print "<b>" . $group_info["group"] . "</b> "; 
 
$exec_begin = exact_millisec() ; 

// EXECUTE MESSAGE LOOKUP
// -----------------------------------------------------------------------'
$page_hash_table = NULL;
if (strlen($_GET["fu"]) > 0)
{  // search the group for specific users   
	$result=$nntp->search_newsgroup(1, "*" . $_GET["fu"] . "*", "from");
	$page_list  = $result["pages"];
	$list_count = count ($result["articles"]);  
	
	if ($start_id=="" || $start_id < $result["articles"][0]->nntp_message_id)
	{
	   $start_id = $result["articles"][0]->nntp_message_id; 
	}
    $lc = 0;
	$nzb_arr = array();
    while (list ($a,$b) = each ($result["articles"])) 
	{ 
		if ($lc > RESULT_PAGE_SIZE)
		{
			break;
		}  
		if ($b->nntp_message_id >= $start_id)
		{ 
		    $lc++;
			$nzb_arr[count($nzb_arr)] = $b->nntp_message_id; 
		}
	}	
	 
	$nzb_min = min ($nzb_arr);
	$nzb_max = max ($nzb_arr);
	 
	
	$new_nzb = $nntp->get_message_summary($nzb_min, $nzb_max, "//", true);
	 
	
    $page_hash_table = array();
    while (list ($a,$b) = each ($new_nzb["articles"])) 
	{ 
	     $page_hash_table[ "k_".$b->nntp_message_id ] = $b;
	}
	reset ($page_hash_table );
	 
}
else if (strlen($search_param) == 0)
{  // look up all articles in the group                     
	$page_list  = $nntp->get_article_list($group_name);                                                                     
	$result     = $nntp->get_message_summary( $page_list[(count($page_list) - $start_at)-1] ); 
	$list_count = $group_info["count"];
}
else 
{  // search the group for specific articles      
	# $result=$nntp->search_newsgroup(1, "*" . $search_param . "*", "from");
	$result=$nntp->search_newsgroup(1, "*" . $search_param . "*");
	$page_list  = $result["pages"];
	$list_count = count ($result["articles"]);
	print "<!-- ";
	print_r ($result["exectime"]);
	print " --> ";

}
$exec_end  =  exact_millisec() ;
$exec_span = $exec_end-$exec_begin ; 
  
print $list_count . " articles.  ";
  
// LIST NAVIGATION LINKS
// -----------------------------------------------------------------------'
$first_page = floor($start_at / 10) * 10;                                                                                                          
$last_page = $first_page + 10; 

if ($last_page>count($page_list))
{
	$last_page = count($page_list);
}
if ($first_page > 0)
{
	print "<a class='normal' href='javascript:fb_edit (\"s\", ". ($first_page-1) . ")'>&laquo; Previous</a> | ";
}
else
{
	print "&laquo; | ";
}

for ($x=$first_page;$x<$last_page;$x++) 
{ 
	if ( $start_at==$x ) 
	{ 
		print "<b>" . ($x+1) . "</b> | "; 
	} 
	else 
	{ 
		print "<a class='normal' href='javascript:fb_edit (\"s\", ".$x.",\"k\", ".$page_list[$x].")'>" . ($x+1) . "</a> | "; 
	}                                                                                                               
} 
if ($x<count($page_list))
{
    print "<a class='normal' href='javascript:fb_edit (\"s\", ".$x.")'>Next &raquo;</a>"; 
}
else
{
	print "&raquo;";
}
  $start_id = $page_list[(count($page_list) - $start_at)-1];
  $end_id   = $page_list[$start_at+1];
  
   print "  " . $start_id . "-" . $end_id;
?>

		 	</div>
		 </td>
		 <td align="right">
		 	<div id="dmetrics">
	 
 <?
// LIST NAVIGATION LINKS
// -----------------------------------------------------------------------'
 print "<b>" . ($first_page+1) . "</b> - <b>" . $last_page . "</b> of 
      <a class='normal' href='javascript:fb_edit(\"s\", \"" . (count ($page_list)-1) . "\")'><b>" . count ($page_list) . "</b></a> pages.";
 if (strlen($search_param) > 0)
 {
	 print " for <a class='normal' href='javascript:fb_edit(\"fi\", \"" . $search_param . "\")'><b>" . $search_param . "</b></a>";
 }
 print " (" . number_format($exec_span , 2) . " secs) "; 
 ?>
	 
	 		</div>
		</td>
  </tr>
</table>
</div>

 